<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
		$id=$_RQ['id'];
		if(!$id){
			exi('请选择优惠券','error');
		}	
		$log=pdo_get('jy_weishop_coupon_getlog',array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		$coupon=$this->model('coupon')->intcoupon($log['couponid'],$log['createtime']);
		$coupon['limitgoodids']= explode(';', $coupon['limitgoodids']);
		$coupon['limitgoodids']= substr(implode(',', $coupon['limitgoodids']),1,strlen(implode(',', $coupon['limitgoodids']))-2);
		$coupon['limitgoodcateids']= explode(';', $coupon['limitgoodcateids']);
		$coupon['limitgoodcateids']= substr(implode(',', $coupon['limitgoodcateids']),1,strlen(implode(',', $coupon['limitgoodcateids']))-2);
		if ($coupon['limitgoodtype'] != 0) {
				if (!empty($coupon['limitgoodids'])) {
					$where = 'and id in(' . $coupon['limitgoodids'] . ')';
				}
				$goods = pdo_fetchall('select `title` from ' . tablename('jy_weishop_goods') . ' where uniacid=:uniacid ' . $where, array(':uniacid' => $_SESSION['uniacid']), 'id');
		}
		if ($coupon['limitgoodcatetype'] != 0) {
				if (!empty($coupon['limitgoodcateids'])) {
					$where = 'and id in(' . $coupon['limitgoodcateids'] . ')';
				}
				$group = pdo_fetchall('select `title`  from ' . tablename('jy_weishop_goods_group') . ' where uniacid=:uniacid   ' . $where, array(':uniacid' => $_SESSION['uniacid']), 'id');
			}
		$return['setting']=$this->plugin_setting('coupon');
		$return['goods']=$goods;
		$return['group']=$group;
		$return['coupon']=$coupon;
	exi($return);
}

?>